package com.task.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.util.ObjectUtils;

/**
 * @Author 迪迦.
 * @Date 2023/5/18 17:41
 */
public enum ImportStatusEnum {
  IMPORTING(1, "importing", "正在导入"),
  FAILED(2, "failed", "失败"),
  END(3, "end", "完毕"),
  PAUSE(4, "pause", "暂停"),
  STOP(5, "stop", "停止"),
  EXPORTING(6, "importing", "正在导出"),

  ;

  private Integer info;
  private String displayName;
  private String msg;


  ImportStatusEnum(Integer info, String displayName, String msg) {
    this.info = info;
    this.displayName = displayName;
    this.msg = msg;
  }

  public static ImportStatusEnum getEnumByInfo(int info) {
    if (!ObjectUtils.isEmpty(info)) {
      for (ImportStatusEnum value : ImportStatusEnum.values()) {
        if (info == value.getInfo()) {
          return value;
        }
      }
    }
    return ImportStatusEnum.IMPORTING;
  }

  /**
   * 获取列表.
   */
  public static List<Map<String, Object>> getList() {
    List<Map<String, Object>> list = new ArrayList<>();
    for (ImportStatusEnum value : ImportStatusEnum.values()) {
      Map<String, Object> map = new HashMap<>();
      map.put("value", value.name());
      map.put("label", value.getMsg());
      map.put("displayName", value.getDisplayName());
      list.add(map);
    }
    return list;
  }

  ImportStatusEnum() {
  }

  public Integer getInfo() {
    return info;
  }

  public String getDisplayName() {
    return displayName;
  }

  public String getMsg() {
    return msg;
  }
}
